﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Wild2.Models.Pages.Controls.BlogsTopicList>" %>
<% 
    if (Model.TopicList.Count > 0)
    {
        foreach (var Topic in Model.TopicList)
        { %>
<div class="elb">
    <div class="elbcap">
        <%= (Topic.Star) ? "*" : "" %><%= Topic.Rating %> <%= Html.ActionLink(Topic.TopicName, "Index", "SandboxTopic", new { id = Topic.TopicID }, new { })%>
    </div>
    <div class="elbcont" style="color: #808080">
        <% 
           if (Topic.UserID > 0)
           { %>
           <%= Html.ActionLink(Topic.UserNick, "Index", "User", new { id = Topic.UserID }, new { })%>
        <% } else { %>
            <%= HttpUtility.HtmlEncode(Topic.UserNick) %>
        <% } %>
        <%= Wild2.Models.Text.Helper.GetDateDiff(Topic.Date)%>
    </div>
    <div class="elbcont">
        <%= Wild2.Models.Text.Helper.smiles(Wild2.Models.Text.Helper.Bbcode(Wild2.Models.Text.Helper.nbsp(Server.HtmlEncode(Wild2.Models.Text.Helper.Cutstring(Topic.Text, 250, 250))), false), 5, 1) %>
    </div>
    <div class="elbcont">
        <% String commentsLink = Topic.CommentsCount + " ";
           if (Topic.CommentsCount % 10 == 0 || (Topic.CommentsCount % 10 >= 5 && Topic.CommentsCount % 10 <= 9)) commentsLink += "комментариев";
           if (Topic.CommentsCount % 10 == 1) commentsLink += "комментарий";
           if (Topic.CommentsCount % 10 >= 2 && Topic.CommentsCount % 10 <= 4) commentsLink += "комментария";
           int lastpage = 1;
           int elonpage = 10;
           if (ConfigurationManager.AppSettings["elonpage"] != null) { elonpage = Int32.Parse(ConfigurationManager.AppSettings["elonpage"]) * 2; }
           if (Topic.CommentsCount % elonpage == 0) lastpage = Topic.CommentsCount / elonpage;
           else { lastpage = (int)Math.Truncate((float)Topic.CommentsCount / (float)elonpage) + 1; }
        %>
        <%= Html.ActionLink(commentsLink, "Index", "SandboxTopic", new { id = Topic.TopicID, p = lastpage }, new { })%>
    </div>
</div>
<%       
        }
    }
    else
    {%>
<div style="padding: 0.4em" class="menuitem">
    Более старые записи не найдены. Вернитесь назад</div>
<%   }
    
%>
